package com.cuanbobox.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import androidx.appcompat.widget.AppCompatTextView;
import com.cuanbobox.bean.DataList;
import com.cuanbobox.cbavcx.R;

/**
 * 单指令单状态的图片
 */
public class SingleCmdTextView extends AppCompatTextView implements View.OnClickListener {
    public String tag;
    private boolean enablePopupWindow;
    private int voiceOffset;

    public SingleCmdTextView(Context context) {
        this(context, null);
    }

    public SingleCmdTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SingleCmdTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.singlecmdtextview, defStyle, 0);
        enablePopupWindow = a.getBoolean(R.styleable.singlecmdtextview_enablePW, false);
        voiceOffset=a.getInteger(R.styleable.singlecmdtextview_voiceOffset,10);
        setOnClickListener(this);
        tag = (String) getTag();
    }


    @Override
    public void onClick(View v) {
        executeCMD();
    }

    private void executeCMD() {
        String cmd = (String) getTag();
        DataList.add(cmd);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
    }

}
